﻿// Copyright (c) 2014 Jonathan Magnan (http://jonathanmagnan.com/).
// All rights reserved (http://zzzproject.com/sqlbulkcopy-extensions/).
// Licensed under MIT License (MIT) (https://zsqlbulkcopy.codeplex.com/license/).
using System.Collections.Generic;
using System.Data.SqlClient;
#if NET20
using Z.Net.Legacy20;
#elif NET35 || NET40
using System.Linq;
#endif

namespace Z.Net.Extensions
{
    internal partial class SqlBulkOperation
    {
        /// <summary>
        ///     Adds custom setting.
        /// </summary>
        public void AddCustomSetting()
        {
            if (SqlBulkCopy.BatchSize > 0)
            {
                SqlBulkCopy.ColumnMappings.Add(TemporaryColumnName, TemporaryColumnName);
#if NET20
                MappingList = new List<SqlBulkCopyColumnMapping>(CollectionBaseExtensions.Cast<SqlBulkCopyColumnMapping>(SqlBulkCopy.ColumnMappings));
#elif NET35 || NET40
                MappingList = SqlBulkCopy.ColumnMappings.Cast<SqlBulkCopyColumnMapping>().ToList();
#endif

            }
        }
    }
}